//
//  IMPVistorTableViewController.swift
//  MySina
//
//  Created by imppppp on 16/5/22.
//  Copyright © 2016年 IMP. All rights reserved.
//

import UIKit

class IMPVistorTableViewController: UITableViewController{
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    var userLogin = false
    
    override func loadView() {
        
//        if userLogin {
//            
//            super.loadView()
//        }else{
//            
//            self.setupVistorView()
//        }
        // 简写1.0
//        userLogin == true ? super.loadView() : self.setupVistorView()
        // 简写2.0
        userLogin ? super.loadView() : self.setupVistorView()
        
        
    }
    
    lazy var visitorView: IMPVistorView = IMPVistorView()
    
    private func setupVistorView() {
        
        self.view = visitorView
//        visitorView.delegate = self
//        view.backgroundColor = UIColor.grayColor()
        
        // 添加导航栏按钮
//        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登陆", style: .Plain, target: self, action: nil)
//        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: nil)
        
        
        visitorView.loginBtn.addTarget(self, action: #selector(userWillLogin), forControlEvents: .TouchUpInside)
        visitorView.registerBtn.addTarget(self, action: #selector(userWillRegister), forControlEvents: .TouchUpInside)
    }
    
    
    func userWillLogin() {
        
        let nav = UINavigationController(rootViewController: IMPOAuthViewController())
        
        presentViewController(nav, animated: true, completion: nil)
    }
    
    func userWillRegister() {
        print("register")
    }

}
